{
  "cells": [
    {
      "cell_type": "markdown",
      "source": [
        "# Gradient Ascent"
      ],
      "metadata": {}
    },
    {
      "cell_type": "code",
      "source": [
        "import numpy as np\n",
        "import matplotlib.pyplot as plt\n",
        "import pandas as pd\n",
        "\n",
        "import warnings\n",
        "warnings.filterwarnings(\"ignore\")\n",
        "\n",
        "# yahoo_finance is used to fetch data \n",
        "import yfinance as yf\n",
        "yf.pdr_override()"
      ],
      "outputs": [],
      "execution_count": 1,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2021-06-22T01:59:36.164Z",
          "iopub.execute_input": "2021-06-22T01:59:36.168Z",
          "iopub.status.idle": "2021-06-22T01:59:36.452Z",
          "shell.execute_reply": "2021-06-22T01:59:36.471Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# input\n",
        "symbol = 'AMD'\n",
        "start = '2014-01-01'\n",
        "end = '2019-01-01'\n",
        "\n",
        "# Read data \n",
        "dataset = yf.download(symbol,start,end)\n",
        "\n",
        "# View Columns\n",
        "dataset.head()"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "[*********************100%***********************]  1 of 1 completed\n"
          ]
        },
        {
          "output_type": "execute_result",
          "execution_count": 2,
          "data": {
            "text/plain": "            Open  High   Low  Close  Adj Close    Volume\nDate                                                    \n2014-01-02  3.85  3.98  3.84   3.95       3.95  20548400\n2014-01-03  3.98  4.00  3.88   4.00       4.00  22887200\n2014-01-06  4.01  4.18  3.99   4.13       4.13  42398300\n2014-01-07  4.19  4.25  4.11   4.18       4.18  42932100\n2014-01-08  4.23  4.26  4.14   4.18       4.18  30678700",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Open</th>\n      <th>High</th>\n      <th>Low</th>\n      <th>Close</th>\n      <th>Adj Close</th>\n      <th>Volume</th>\n    </tr>\n    <tr>\n      <th>Date</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>2014-01-02</th>\n      <td>3.85</td>\n      <td>3.98</td>\n      <td>3.84</td>\n      <td>3.95</td>\n      <td>3.95</td>\n      <td>20548400</td>\n    </tr>\n    <tr>\n      <th>2014-01-03</th>\n      <td>3.98</td>\n      <td>4.00</td>\n      <td>3.88</td>\n      <td>4.00</td>\n      <td>4.00</td>\n      <td>22887200</td>\n    </tr>\n    <tr>\n      <th>2014-01-06</th>\n      <td>4.01</td>\n      <td>4.18</td>\n      <td>3.99</td>\n      <td>4.13</td>\n      <td>4.13</td>\n      <td>42398300</td>\n    </tr>\n    <tr>\n      <th>2014-01-07</th>\n      <td>4.19</td>\n      <td>4.25</td>\n      <td>4.11</td>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>42932100</td>\n    </tr>\n    <tr>\n      <th>2014-01-08</th>\n      <td>4.23</td>\n      <td>4.26</td>\n      <td>4.14</td>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>30678700</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 2,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2021-06-22T01:59:36.459Z",
          "iopub.execute_input": "2021-06-22T01:59:36.462Z",
          "iopub.status.idle": "2021-06-22T01:59:37.111Z",
          "shell.execute_reply": "2021-06-22T01:59:37.193Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "dataset.tail()"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 3,
          "data": {
            "text/plain": "                 Open       High        Low      Close  Adj Close     Volume\nDate                                                                        \n2018-12-24  16.520000  17.219999  16.370001  16.650000  16.650000   62933100\n2018-12-26  16.879999  17.910000  16.030001  17.900000  17.900000  108811800\n2018-12-27  17.430000  17.740000  16.440001  17.490000  17.490000  111373000\n2018-12-28  17.530001  18.309999  17.139999  17.820000  17.820000  109214400\n2018-12-31  18.150000  18.510000  17.850000  18.459999  18.459999   84732200",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Open</th>\n      <th>High</th>\n      <th>Low</th>\n      <th>Close</th>\n      <th>Adj Close</th>\n      <th>Volume</th>\n    </tr>\n    <tr>\n      <th>Date</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>2018-12-24</th>\n      <td>16.520000</td>\n      <td>17.219999</td>\n      <td>16.370001</td>\n      <td>16.650000</td>\n      <td>16.650000</td>\n      <td>62933100</td>\n    </tr>\n    <tr>\n      <th>2018-12-26</th>\n      <td>16.879999</td>\n      <td>17.910000</td>\n      <td>16.030001</td>\n      <td>17.900000</td>\n      <td>17.900000</td>\n      <td>108811800</td>\n    </tr>\n    <tr>\n      <th>2018-12-27</th>\n      <td>17.430000</td>\n      <td>17.740000</td>\n      <td>16.440001</td>\n      <td>17.490000</td>\n      <td>17.490000</td>\n      <td>111373000</td>\n    </tr>\n    <tr>\n      <th>2018-12-28</th>\n      <td>17.530001</td>\n      <td>18.309999</td>\n      <td>17.139999</td>\n      <td>17.820000</td>\n      <td>17.820000</td>\n      <td>109214400</td>\n    </tr>\n    <tr>\n      <th>2018-12-31</th>\n      <td>18.150000</td>\n      <td>18.510000</td>\n      <td>17.850000</td>\n      <td>18.459999</td>\n      <td>18.459999</td>\n      <td>84732200</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 3,
      "metadata": {
        "collapsed": true,
        "jupyter": {
          "source_hidden": false,
          "outputs_hidden": false
        },
        "nteract": {
          "transient": {
            "deleting": false
          }
        },
        "execution": {
          "iopub.status.busy": "2021-06-22T01:59:37.117Z",
          "iopub.execute_input": "2021-06-22T01:59:37.121Z",
          "iopub.status.idle": "2021-06-22T01:59:37.131Z",
          "shell.execute_reply": "2021-06-22T01:59:37.197Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "X = dataset.iloc[ : , 1].values\n",
        "y = dataset.iloc[ : , 4].values"
      ],
      "outputs": [],
      "execution_count": 4,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2021-06-22T01:59:37.138Z",
          "iopub.execute_input": "2021-06-22T01:59:37.141Z",
          "iopub.status.idle": "2021-06-22T01:59:37.147Z",
          "shell.execute_reply": "2021-06-22T01:59:37.201Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "print(X.shape)\n",
        "print(y.shape)"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "(1258,)\n",
            "(1258,)\n"
          ]
        }
      ],
      "execution_count": 5,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2021-06-22T01:59:37.153Z",
          "iopub.execute_input": "2021-06-22T01:59:37.156Z",
          "iopub.status.idle": "2021-06-22T01:59:37.165Z",
          "shell.execute_reply": "2021-06-22T01:59:37.204Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "plt.title('Scatter Plot of X & y')\n",
        "plt.xlabel('Independent Variable')\n",
        "plt.ylabel('Depdent Variable')\n",
        "plt.scatter(X, y)"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 6,
          "data": {
            "text/plain": "<matplotlib.collections.PathCollection at 0x1c23371f9e8>"
          },
          "metadata": {}
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": "<Figure size 432x288 with 1 Axes>",
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEWCAYAAABhffzLAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAow0lEQVR4nO3de5RcVZn38e+vOwV0uEwnEjMQCEFUHBEJTosgLF8GBUYZMDIIsmAExwFn1FdRjAbkNUFRohHQ0VEERVACErm0ICqggAjDxYQORIQMIgi2yEWNBMhA0nneP84pqFSqqk/X/fL7rNUrVafO5elK8tSuffZ+tiICMzPrHX2tDsDMzJrLid/MrMc48ZuZ9RgnfjOzHuPEb2bWY5z4zcx6jBO/WUaSFki6sEnX2lvS/ZKeljSnGde03uHEb3UnaR9J/y3pr5L+LOkWSa+v8ZzHSrq5aNv5kk6rLdqNrnO+pOfThPtnSddJelUV53lI0ltqCOXTwFcjYouIGC469xbp+Y8q2LalpIclHVYhpqPT456SdLuk7WqIzzqYE7/VlaStgB8CXwGmAjOAU4HnWhlXKZImlXnpCxGxBbAd8DhwftOCetEOwD2lXoiIp4H3AV+SNC3d/AVgaURcWuoYSVsA3waOBwaBDwL/W+eYrUM48Vu9vRIgIi6OiLGIWBMR10bE3fkdJB0n6V5JqyX9WtLr0u3zJD1QsP0d6fa/A84G9kpb4qskHQ8cBXw83XZVuu+2ki6T9ISkByV9qOC6CyRdKulCSU8Bx1b6RSLiWeAi4DWlXpd0iKR70nhuTONE0neBmcBVaWwfL3P8cZJ+k36zuFLStun2B4CXFRy/aYnYrgGuBv5T0r7A4cD7K/06wDrgwYhYHxG/jIgny+0s6W8lPSvpJQXbXpe+r7kK17FOEBH+8U/dfoCtgD8BFwBvBaYUvf5OYBR4PSDg5cAOBa9tS9IgOQJ4Btgm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53h0k9eHvJuk2WRoRvwZOIVkJ7W6S1ZYKSweX8mGShXNWULAKU0RcC1wE3Jq+dimVkzrA+cDZxTd3C1xH0r9/ScG3jwXA9yUtA7Ku1/wF4HRJI2z8rWmj96XwxSp/L+twrs5pHU/SsSQ3LT/Y6ljMOoFb/GZmPcYtfjOzHuMWv5lZj3HiNzPrMU78ZmY9xonfzKzHOPGbmfWY/w/SWCSeVsy6VAAAAABJRU5ErkJggg==\n"
          },
          "metadata": {
            "needs_background": "light"
          }
        }
      ],
      "execution_count": 6,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2021-06-22T01:59:37.172Z",
          "iopub.execute_input": "2021-06-22T01:59:37.176Z",
          "iopub.status.idle": "2021-06-22T01:59:37.267Z",
          "shell.execute_reply": "2021-06-22T01:59:37.325Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "#X = np.array(X).reshape(1258,-1)\n",
        "#y = np.array(y).reshape(1258,-1)"
      ],
      "outputs": [],
      "execution_count": 7,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2021-06-22T01:59:37.274Z",
          "iopub.execute_input": "2021-06-22T01:59:37.277Z",
          "iopub.status.idle": "2021-06-22T01:59:37.285Z",
          "shell.execute_reply": "2021-06-22T01:59:37.328Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "#X = X[:,0]\n",
        "#y = y[:,0]"
      ],
      "outputs": [],
      "execution_count": 8,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2021-06-22T01:59:37.292Z",
          "iopub.execute_input": "2021-06-22T01:59:37.298Z",
          "iopub.status.idle": "2021-06-22T01:59:37.307Z",
          "shell.execute_reply": "2021-06-22T01:59:37.331Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from scipy.stats import linregress\n",
        "\n",
        "slope, intercept, r_squared, p_value, std_err = linregress(X, y)\n",
        "print(\"slope:\", round(slope,3) , \"intercept:\", round(intercept, 3))"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "slope: 0.972 intercept: 0.045\n"
          ]
        }
      ],
      "execution_count": 9,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2021-06-22T01:59:37.313Z",
          "iopub.execute_input": "2021-06-22T01:59:37.317Z",
          "shell.execute_reply": "2021-06-22T01:59:37.567Z",
          "iopub.status.idle": "2021-06-22T01:59:37.547Z"
        }
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "# f(x) = 2*x - x^2\n"
      ],
      "metadata": {
        "nteract": {
          "transient": {
            "deleting": false
          }
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "origin = lambda X: 2 * X - X ** 2\n",
        "plt.plot(X, origin(X), c='black')  # Visualization\n",
        "# Derivative of the original function\n",
        "derivative = lambda X: 2 - 2 * X\n",
        "# Gradient rising demand\n",
        "extreme_point = 0  # Initial value\n",
        "alpha = 0.1  # Step, that is the learning rate\n",
        "presision = 0.001  # Range of tolerance\n",
        "while True:\n",
        "    plt.scatter(extreme_point, origin(extreme_point))  # Visualization\n",
        "    error = alpha * derivative(extreme_point)  # Climbing pace\n",
        "    extreme_point += error  # Climbing\n",
        "    if abs(error) < presision:\n",
        "        break  # Exit iterative error is small\n",
        "plt.show()"
      ],
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/plain": "<Figure size 432x288 with 1 Axes>",
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAD4CAYAAAAD6PrjAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAfpElEQVR4nO3deXxU9b3/8ddnCGExLYStRmSreEXw0VIYEDeKlk16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MqAtMV3PB8gbW17ms2C2YfBy4Cyg/BdsnNZxdXmPSH0shbbAmpT5tcT8P9KAA8+aWaGZjY86zGH4krsXB9PrgS9FGeYQXW5m7wS7l2KxG6YqZtYR+BrwOlmwnivlhRivZzNrYGaLgY3AXOADYJu77wsWidXvjcp53b18Hf8yWMf3mFmjQ/ms+lgK2ep0d+8BnA1cFuz6yCpetq8y7vsrJwHHAd2BYuDXkaaphpnlAX8Ffujun6a+F8f1XEXeWK9ndy9x9+7AsZTtXegSbaIDq5zXzE4CbqAsdy+gBXBIuxPrYymsA9qlzB8bjMWau68L/rkR+Btl/6Fmgw3BfuXy/csbI85zQO6+IfgfrBT4HTFcz8F+478Cf3L3J4Ph2K7nqvJmw3oGcPdtwAvAKUBzM8sJ3orl742UvIODXXfu7ruByRziOq6PpbAQOD44kyAXGAHMijjTAZnZUcFBOszsKGAg8N6Bfyo2ZgGjg+nRwMwIsxxU+S/WwDnEbD0HBxUfBpa5+90pb8VyPVeXN87r2cxam1nzYLoJZSelLKPsl+3wYLE4reOq8v4r5Y8Eo+z4xyGt43p39hFAcPrbvUAD4BF3/2W0iQ7MzL5M2dYBQA4wJY6ZzezPQD/Kbtm7AbgRmAFMA9pTdovz8909Fgd3q8nbj7JdGg6sAv5fyr76yJnZ6cAC4F2gNBj+CWX76WO3ng+Q90Jiup7N7CuUHUhuQNkfztPc/ebg/8OplO2KeQv4bvBXeKQOkPd5oDVgwGJgQsoB6eo/rz6WgoiIVK0+7j4SEZFqqBRERCSkUhARkZBKQUREQioFEREJqRRERCSkUhARkdD/B/OcFNn7sC0WAAAAAElFTkSuQmCC\n"
          },
          "metadata": {
            "needs_background": "light"
          }
        }
      ],
      "execution_count": 10,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2021-06-22T01:59:37.553Z",
          "iopub.execute_input": "2021-06-22T01:59:37.558Z",
          "iopub.status.idle": "2021-06-22T01:59:37.776Z",
          "shell.execute_reply": "2021-06-22T01:59:37.800Z"
        }
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "# # f'(x) = 2 - 2*x"
      ],
      "metadata": {
        "nteract": {
          "transient": {
            "deleting": false
          }
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "derivative = lambda X: 2 - 2 * X  # (2-x ** 2) derivative\n",
        "extreme_point = 0  # Initial value\n",
        "alpha = 0.1  # Step, that is the learning rate\n",
        "presision = 0.0001  # Range of tolerance\n",
        "while True:\n",
        "    error = alpha * derivative(extreme_point)  # Climbing pace\n",
        "    extreme_point += error # Climbing\n",
        "    print(extreme_point)\n",
        "    if abs(error) < presision:\n",
        "        break"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "0.2\n",
            "0.36000000000000004\n",
            "0.488\n",
            "0.5904\n",
            "0.67232\n",
            "0.7378560000000001\n",
            "0.7902848\n",
            "0.83222784\n",
            "0.865782272\n",
            "0.8926258176\n",
            "0.9141006540800001\n",
            "0.931280523264\n",
            "0.9450244186112\n",
            "0.95601953488896\n",
            "0.9648156279111679\n",
            "0.9718525023289344\n",
            "0.9774820018631475\n",
            "0.981985601490518\n",
            "0.9855884811924144\n",
            "0.9884707849539315\n",
            "0.9907766279631451\n",
            "0.9926213023705162\n",
            "0.9940970418964129\n",
            "0.9952776335171303\n",
            "0.9962221068137043\n",
            "0.9969776854509634\n",
            "0.9975821483607707\n",
            "0.9980657186886166\n",
            "0.9984525749508932\n",
            "0.9987620599607145\n",
            "0.9990096479685716\n",
            "0.9992077183748573\n",
            "0.9993661746998859\n",
            "0.9994929397599087\n",
            "0.999594351807927\n",
            "0.9996754814463416\n"
          ]
        }
      ],
      "execution_count": 11,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2021-06-22T01:59:37.782Z",
          "iopub.execute_input": "2021-06-22T01:59:37.788Z",
          "iopub.status.idle": "2021-06-22T01:59:37.797Z",
          "shell.execute_reply": "2021-06-22T01:59:37.804Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "derivative = lambda X: np.cos(X)  # Sin (x) derivative\n",
        "extreme_point = np.random.randint(0, 100)  # Initialize extreme points\n",
        "print(extreme_point)\n",
        "for i in range(1, 99999):\n",
        "    alpha = 1 / i  # Step (slow down after)\n",
        "    extreme_point += alpha * derivative(extreme_point)\n",
        "print(extreme_point)\n",
        "print(extreme_point % (np.pi * 2))"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "10\n",
            "7.853999717751118\n",
            "1.5708144105715318\n"
          ]
        }
      ],
      "execution_count": 12,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2021-06-22T01:59:37.814Z",
          "iopub.execute_input": "2021-06-22T01:59:37.820Z",
          "shell.execute_reply": "2021-06-22T01:59:37.911Z",
          "iopub.status.idle": "2021-06-22T01:59:37.917Z"
        }
      }
    }
  ],
  "metadata": {
    "kernel_info": {
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3.6.12",
      "mimetype": "text/x-python",
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "pygments_lexer": "ipython3",
      "nbconvert_exporter": "python",
      "file_extension": ".py"
    },
    "kernelspec": {
      "name": "python3",
      "language": "python",
      "display_name": "Python 3"
    },
    "nteract": {
      "version": "0.28.0"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}